<template>
  <div class="head">
    <div class="tit">
      <button class="tex1">出港操作费报表</button>
    </div>
    <div class="line" />
    <el-row>
      <el-col :span="24">
        <div class="title1">
          <el-form
            ref="form"
            style="display: flex;flex-wrap: wrap;margin-top: 24px;justify-content: space-between;"
            :model="form"
            label-width="80px"
          >
            <div style="display: flex;justify-content: space-between;flex-wrap: wrap;width: 1578px;">
              <el-form-item
                class="text"
                label="日期"
              >
                <el-date-picker
                  v-model="value"
                  type="daterange"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                  style="width: 690px"
                  @change="changeTime"
                />
              </el-form-item>
              <el-form-item
                class="text"
                label="日期维度"
                required
              >
                <el-select
                  v-model="form.dateType"
                  class="input"
                  placeholder="请选择"
                  style="width: 286px;"
                >
                  <el-option
                    label="按天"
                    value="1"
                  />
                  <el-option
                    label="按时间段"
                    value="2"
                  />
                </el-select>
              </el-form-item>
              <el-form-item
                class="text"
                label="汇总维度"
              >
                <el-select
                  v-model="form.collectType"
                  class="input"
                  placeholder="请选择"
                  style="width: 286px;"
                  @change="changeType"
                >
                  <el-option
                    label="客户+承包区+网点+中心"
                    value="1"
                  />
                  <el-option
                    label="承包区+网点+中心"
                    value="2"
                  />
                  <el-option
                    label="网点+中心"
                    value="3"
                  />
                  <el-option
                    label="网点"
                    value="4"
                  />
                  <el-option
                    label="客户+承包区+网点"
                    value="5"
                  />
                </el-select>
              </el-form-item>
            </div>
            <div>
              <el-form-item>
                <el-button
                  type="primary"
                  @click="onSubmit"
                >查询</el-button>
                <el-button @click="khClear">重置</el-button>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="title1">
          <el-form
            ref="form"
            style="display: flex;justify-content: space-between;flex-wrap: wrap;"
            :model="form"
            label-width="80px"
          >
            <div style="display: flex;justify-content: space-between;flex-wrap: wrap;width: 770px;">
              <el-form-item
                class="text"
                label="结算对象"
              >
                <el-select
                  v-model="form.networkName"
                  :disabled="true"
                  placeholder="辽宁盘锦公司"
                  style="width: 286px;"
                >
                  <el-option
                    label="辽宁盘锦公司"
                    value="1"
                  />
                </el-select>
              </el-form-item>
            </div>
            <div>
              <el-form-item>
                <el-button @click="onSubmit"><i class="el-icon-upload2" />导出</el-button>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <el-table
          v-loading="loading"
          :data="tableData"
          border
          max-height="734"
          :header-cell-style="{ background: '#f6f6f6' }"
          style="width: 100%"
        >
          <el-table-column
            type="index"
            :index="table_index"
            width="50"
            align="center"
          />
          <el-table-column
            prop="collectDate"
            label="结算日期"
            width="180"
            align="center"
          />
          <el-table-column
            prop="networkNameId"
            label="结算对象编号"
            align="center"
          />
          <el-table-column
            prop="networkName.networkName"
            label="结算对象名称"
            align="center"
          />
          <el-table-column
            v-if="form.collectType !== '3' && form.collectType !== '4'"
            prop="contractAreaNameId"
            label="承包区编号"
            align="center"
          />
          <el-table-column
            v-if="form.collectType !== '3' && form.collectType !== '4'"
            prop="contractAreaName.networkName"
            label="承包区名称"
            align="center"
          />
          <el-table-column
            v-if="form.collectType !== '2' && form.collectType !== '3' && form.collectType !== '4'"
            prop="clientId"
            label="客户编码"
            align="center"
          />
          <el-table-column
            v-if="form.collectType !== '2' && form.collectType !== '3' && form.collectType !== '4'"
            prop="client.name"
            label="客户名称"
            align="center"
          />
          <el-table-column
            v-if="form.collectType !== '4' && form.collectType !== '5'"
            prop="hqTransferCentre.transferCode"
            label="转运中心编码"
            align="center"
          />
          <el-table-column
            v-if="form.collectType !== '4' && form.collectType !== '5'"
            prop="hqTransferCentre.transferCenter"
            label="转运中心名称"
            align="center"
          />
          <el-table-column
            prop="policyArea"
            label="政策范围"
            align="center"
          />
          <el-table-column
            label="日结算"
            align="center"
          >
            <el-table-column
              prop="daySettleNum"
              label="结算件量"
              align="center"
            />
            <el-table-column
              prop="daySettleWeight"
              label="结算重量"
              align="center"
            />
            <el-table-column
              prop="daySettleAmount"
              label="结算金额"
              align="center"
            />
          </el-table-column>
          <el-table-column
            label="日追溯"
            align="center"
          >
            <el-table-column
              prop="dayAscendSettleNum"
              label="结算件量"
              align="center"
            />
            <el-table-column
              prop="dayAscendSettleWeight"
              label="结算重量"
              align="center"
            />
            <el-table-column
              prop="dayAscendSettleAmount"
              label="结算金额"
              align="center"
            />
          </el-table-column>
        </el-table>
        <div style="display: flex;justify-content: space-between;margin-top: 51px;">
          <div class="title2" />
          <div
            class="block"
            style="display: flex; justify-content: flex-end"
          >
            <el-pagination
              background
              :current-page="current"
              :page-sizes="[10, 20, 30, 40]"
              :page-size="10"
              layout="total, prev, pager, next"
              :total="+total"
              prev-text="上一页"
              next-text="下一页"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </div>

      </el-col>
    </el-row>
  </div>
</template>

<script>
import { NewDepartureOperationApi } from '@/api/HqFinancePanel'

export default {

  components: {},
  data() {
    return {
      loading: false,
      value: '',
      form: {
        networkName: '',
        collectType: '',
        dateType: '',
        endTime: '',
        networkNameId: '1',
        pageDate: {
          pageNum: 1,
          pageSize: 10
        },
        startTime: ''
      },
      tableData: [],
      current: 0, // 页数
      pages: 0, // 条数
      total: 0 // 总数
    }
  },

  computed: {},

  created() {
  },

  methods: {
    handleSizeChange(val) {
      this.form.pageDate.pageSize = val
      this.onSubmit()
    },
    handleCurrentChange(val) {
      this.form.pageDate.pageNum = val
      this.onSubmit()
    },
    // 序号
    table_index(index) {
      return (this.form.pageDate.pageNum - 1) * this.form.pageDate.pageSize + index + 1
    },
    // 选择时间
    changeTime() {
      if (this.value != null) {
        this.form.startTime = this.value[0]
        this.form.endTime = this.value[1]
      }
    },
    // 重置
    khClear() {
      Object.keys(this.form).forEach((key) => {
        if (key !== 'pageDate' && key !== 'networkNameId') {
          this.form[key] = ''
        }
      })
      this.tableData = []
      this.value = ''
      this.total = 0
      this.current = 0
      this.pages = 0
    },
    // 查询
    async onSubmit() {
      const res = await NewDepartureOperationApi(this.form)
      this.loading = true
      if (res.code == 200) {
        this.tableData = res.data.data
        this.total = res.data.total
        this.current = res.data.current
        this.pages = res.data.pages
      }
      this.loading = false
    },
    changeType() {
      this.tableData = []
    }
  }
}

</script>
<style
  scoped
  lang="scss"
>
.tit {
  display: flex;

  .tex1 {
    margin-right: 48px;
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
    background: #fff;
    border: 1px #fff solid;
  }

  .active {
    font-family: Source Han Sans CN;
    font-weight: 700;
    color: #2087D0;
    position: relative;

  }

  .active::before {
    position: absolute;
    content: '';
    width: 62px;
    height: 2px;
    background: #2087D0;
    border-radius: 1px;
    bottom: -20px;
    left: 50%;
    transform: translate(-50%);
  }
}

.head {
  padding: 30px;
}

.title {
  font-size: 16px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
  margin-top: 20px;
}

.line {
  height: 1px;
  background: #D8D8D8;
  border-radius: 1px;
  margin-top: 19px;
}

.title1 {
  .text {
    font-size: 18px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;

    .input {
      width: 286px;
      height: 36px;
      background: #FFFFFF;
      border-radius: 4px;
    }

    .input1 {
      width: 708px;
      height: 36px;
      background: #FFFFFF;
      border: 1px solid #B4B4B4;
      border-radius: 4px;
    }
  }
}

.title2 {
  font-size: 18px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
}
</style>
